<template>
  <el-form ref="addForm" :model="promotersForm" label-width="120px">
    <el-form-item label="推广员姓名">
      <el-input
        type="input"
        v-model="promotersForm.sharerName"
        size="small"
        placeholder="请输入推广员姓名"
      ></el-input>
    </el-form-item>
    <el-form-item label="手机号码">
      <el-input
        type="input"
        v-model="promotersForm.phone"
        size="small"
        placeholder="请输入手机号码"
      ></el-input>
    </el-form-item>
    <el-form-item label="登录账号">
      <el-input
        type="input"
        v-model="promotersForm.userCode"
        size="small"
        placeholder="请输入登录账号"
      ></el-input>
    </el-form-item>
    <el-form-item label="登录密码">
      <el-input
        type="input"
        v-model="promotersForm.userPwd"
        size="small"
        placeholder="请输入登录密码"
      ></el-input>
    </el-form-item>
    <div class="dividing-line m-t-20 m-b-20"></div>
    <div class="flex-end">
      <el-button type="primary" size="small" plain @click="back"
        >取消</el-button
      >
      <el-button
        type="primary"
        size="small"
        @click="submitPromoters"
        :loading="loading"
        >确定</el-button
      >
    </div>
  </el-form>
</template>
<script>
import { submit } from "@/api/marketing-management/promoters";
export default {
  data() {
    return {
      loading: false,
    };
  },
  props: {
    promotersType: {
      type: String,
      default: "add",
    },
    promotersForm: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  methods: {
    back() {
      this.$emit("back");
    },
    submitPromoters() {
      this.promotersForm.isPromote = 1;
      this.loading = true;
      submit(this.promotersForm)
        .then((response) => {
          this.loading = false;
          this.$emit("back", "refresh");
        })
        .catch((error) => {
          this.loading = false;
        });
    },
  },
};
</script>
